#include<bits/stdc++.h>
using namespace std;
struct car{
	int d,v,a;
	double road_to_v,out_road;
	double detect_road;
	car():d(0),v(0),a(0){}
	car(int nd,int nv,int na,int nv2,int nl):d(nd),v(nv),a(na){
		if(a==0){
			if(nv>nv2) road_to_v=0.0;
			else road_to_v=nl+1.0;
			out_road=nl+1.0;
		}
		else{
			road_to_v=(pow(nv2,2.0)-pow(nv,2.0))/2.0/na;
			if(a<0){
				if(nv>nv2) road_to_v=0.0;
				else road_to_v=nl+1.0;
				out_road=(pow(nv2,2.0)-pow(nv,2.0))/2.0/na;
			}
			else out_road=nl+1.0;
		}
		detect_road=nd+road_to_v;
		out_road+=d;
	}
};
int t,n,m,l,v;
vector<int> csy,st;
vector<car> cars;
int t1,t2,t3;
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin>>t;
	while(t--){
		st.clear();
		csy.clear();
		cars.clear();
		cin>>n>>m>>l>>v;
		for(int i=1;i<=n;i++){
			cin>>t1>>t2>>t3;
			cars.push_back(car(t1,t2,t3,v,l));
		}
		//for(auto i:cars){
		//	printf("DEBUG: car(d=%d, v=%d, a=%d) detect at: %lf\nout road at: %lf\n",i.d,i.v,i.a,i.detect_road,i.out_road);
		//}
		for(int i=1;i<=m;i++){
			cin>>t1;
			csy.push_back(t1);
			st.push_back(0);
		}
		int ans=0;
		for(int k=0;k<n;k++){
			car i=cars[k];
			for(int j=0;j<csy.size();j++){
				if((i.a>=0&&i.detect_road<csy[j]&&i.out_road>=csy[j])||(i.a<0&&i.detect_road<=csy[j]&&i.out_road>csy[j])){
					st[j]=1;
					ans++;
					//printf("DEBUG: csy[%d] had used to check car[%d]\n",j,k);
					break;
				}
			}
		}
		cout<<ans<<' ';
		ans=0;
		for(auto i:st){
			if(i) ans++;
		}
		cout<<st.size()-ans<<endl;
	}
	return 0;
}
